package com.lee.bgTask;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

import java.util.HashMap;
import java.util.Random;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

@SpringBootApplication
public class BgTaskApplication {

    public static void main(String[] args) {
        SpringApplication.run(BgTaskApplication.class, args);
    }

    private static void test() {
        ExecutorService es = Executors.newFixedThreadPool(20);
        BgTaskExcuteCenter center = new BgTaskExcuteCenter();
        center.start();
        for (int i = 0; i < 99999; i++) {
            int index = i;
            es.submit(() -> {

                Random r = new Random(index);
                try {
                    Thread.sleep(r.nextInt(100));
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                MyTaskEntity entity = new MyTaskEntity();
                String x = "code" + index;
                entity.setVaribales(new HashMap() {
                    {
                        put("code", x);
                    }
                });
                center.put(entity);
            });

            if (i % 1000 == 0) {
                center.cleanAll(0);
            }

        }
    }

}
